#ifndef MESSAGEDISPATCHER_H
#define MESSAGEDISPATCHER_H
#include <QMap>
#include <QObject>
#include "Global/singleton.h"
#include "protocol.h"
#include "memory.h"
#include "WorkServe/cuserservice.h"
#include "WorkServe/friendservice.h"
#include "WorkServe/csearchservice.h"
class MessageDispatcher : public QObject,public Singleton<MessageDispatcher>
{
    Q_OBJECT
public:
    friend class Singleton<MessageDispatcher>;
    void DoHandler(myuint Type,std::shared_ptr<PDU>Msg);
    CUserService* getCuserServer();
    FriendService* getFriendServer();
    CSearchService* getCsearchServer();
private:
    CUserService *CuserServer;

    FriendService *FriendServer;

    CSearchService* CsearchServer;

    explicit MessageDispatcher(QObject *parent = nullptr);

    void RegistWork(myuint RecvType,std::function<void(std::shared_ptr<PDU>)> Work);

    QMap<myuint,std::function<void(std::shared_ptr<PDU>)>>Register;

    void ToRegister();
signals:

};

#endif // MESSAGEDISPATCHER_H
